

getSpu();
function getSpu(){
        $.ajax({
             url: "https://www.gongrenbao.cn/index.php?c=api/du/goatspu",
             type: "GET",
             success: function (data) {
                console.log(data);
                 checkData(data['data']['list']);
             }
        });
}

function checkData(ids) {

    var htmldata = "";
    for(j = 0; j < ids.length; j++) {
        var url="https://www.goat.com/web-api/v1/product_variants/buy_bar_data?productTemplateId="+ids[j]['spu_id']+"&countryCode=US"
        htmldata += "<a target='_blank' href='"+url+"'>"+ids[j]['spu_id']+"</a><br>";
    }
    $(".content").html(htmldata);

    $(".content").find("a").each(function(){
        console.log($(this).attr("href"));
         $(this)[0].click();
    })

    setTimeout("window.location.reload()",3000);

}